package com.jing.weibo.service.user;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jing.system.model.PageCls;
import com.jing.weibo.mapper.user.UserCurrencyLogMapper;
import com.jing.weibo.pojo.user.UserCurrencyLog;

/**
 * 用户妞币信息的Service
 * @author jing.yue
 * @version 2012/09/29 1.0.0
 */
@Component
public class UserCurrencyLogService {

	@Autowired
	private UserCurrencyLogMapper userCurrencyLogMapper;

	/**
	 * 保存用户妞币信息
	 * @param userCurrencyLog
	 * @throws Exception
	 */
	public void saveUserCurrencyLog(UserCurrencyLog userCurrencyLog) throws Exception {
		userCurrencyLogMapper.saveUserCurrencyLog(userCurrencyLog);
	}

	/**
	 * 根据用户名获取用户妞币记录信息
	 * @param userCurrencyLog
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> findByUsernameCurrency(UserCurrencyLog userCurrencyLog) throws Exception {
		List<UserCurrencyLog> userCurrencyLogs = userCurrencyLogMapper.findByUsernameCurrency(userCurrencyLog);
		Integer countSize = userCurrencyLogMapper.findByUsernameCurrencyCount(userCurrencyLog);
		PageCls pageCls = PageCls.setPageCls(userCurrencyLog.getPage(), userCurrencyLog.getSize(), null, null, countSize, userCurrencyLogs.size(), userCurrencyLogs);
		return pageCls.getPageInfo();
	}

}